package com.weic.design;

import com.sun.org.apache.xpath.internal.operations.String;
import com.weic.design.event.SubjectEvent;
import com.weic.design.observer.Father;
import com.weic.design.observer.Mother;
import com.weic.design.observer.Observer;
import com.weic.design.subject.Son;
import com.weic.design.subject.Subject;

/**
 * 测试
 */
public class ObserverTest {
    public static void main(String[] args) {
       Subject son = new Son();
        //添加观察者
        Observer one = new Father();
        son.addObserver(one);
        Observer two = new Mother();
        son.addObserver(two);
        //定义事件
        SubjectEvent event = new SubjectEvent("baby cry!",son);
        son.notifyObservers(event);
    }
}
